﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml;
#if L2S
using System.Data.Linq.Mapping;
#endif

namespace ALinq.Mapping
{
    class ModelMappingFactory
    {
        internal static TableMapping<T> CreateTableMapping<T>()
        {
            var tableMapping = new TableMapping<T>();
            return tableMapping;
        }

        internal static ColumnMapping CreateColumnMapping(MemberInfo member)
        {
            var columnMapping = new ColumnMapping(member);

            columnMapping.Name = member.Name;
            //columnMapping.Storage = string.Format("_{0}", member.Name);
            columnMapping.UpdateCheck = UpdateCheck.Never;
            columnMapping.CanBeNull = true;

            return columnMapping;
        }

        internal static AssociationMapping CreateAssociationAttribute(MemberInfo member)
        {
            var assocMapping = new AssociationMapping(member);
            //assocMapping.ThisMember = thisKey;
            //assocMapping.OtherMember = otherKey;

            //var type1 = thisKey[0].DeclaringType;
            //var type2 = otherKey[0].DeclaringType;

            //assocMapping.Name = string.Format("{0}_{1}", type1.Name, type2.Name);
            //assocMapping.Storage = string.Format("_{0}", member.Name);

            return assocMapping;
        }
    }
}
